/**************************************************************************************************
* Title: InputManager.cpp
* Authors: Gael Huber
* Description: Handles mouse and keyboard input.
**************************************************************************************************/
#include "SmurfsInputManager.h"

// Constructor
InputManager::InputManager(void) { }

// Destructor
InputManager::~InputManager(void) { }

// Public Method to access both keyboard and mouse input
void InputManager::handleInput(RenderObject* player, Vector2* ballVelocity) {
	handleKeyboardInput(player, ballVelocity);
	handleMouseInput();
}

// Handles keyboard input
void InputManager::handleKeyboardInput(RenderObject* player, Vector2* ballVelocity) {
	if(GetKeyState(VK_UP) & 0x80) {
		// move up
		player->screenY -= 5;
	} else if((GetKeyState(VK_DOWN) & 0x80)) {
		// move down
		player->screenY += 5;
	} else if((GetKeyState(VK_LEFT) & 0x80)) {
		// move left
	} else if((GetKeyState(VK_RIGHT) & 0x80)) {
		// move right
	} else if((GetKeyState(VK_SPACE) & 0x80)) {
		if(ballVelocity->magnitude() == 0) {
			// start the ball :)
			int xRand = 0;
			while(xRand == 0)
				xRand = rand() % 10 - 5;
			int yRand = 0;
			while(yRand == 0)
				yRand = rand() % 10 - 5;
			ballVelocity->x = (float)xRand;
			ballVelocity->y = (float)yRand;
			ballVelocity->normalize();
		}
	} else if((GetKeyState(VK_ESCAPE) & 0x80)) {
		// Quit the application
		PostQuitMessage(0);
	}
}

// Handles mouse input
void InputManager::handleMouseInput(void) {
	if((GetKeyState(VK_LBUTTON) & 0x80)) {
		int a = 0;
	}
}